package com.ambulance.project.biz.controller.manager;

import com.ambulance.common.utils.poi.ExcelUtil;
import com.ambulance.framework.aspectj.lang.annotation.Log;
import com.ambulance.framework.aspectj.lang.enums.BusinessType;
import com.ambulance.framework.web.controller.BaseController;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.page.TableDataInfo;
import com.ambulance.project.manager.domain.BizClass;
import com.ambulance.project.manager.service.IBizClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 班组管理Controller
 *
 * @author zr
 * @date 2020-05-11
 */
@RestController
@RequestMapping("/manager/class")
public class BizClassController extends BaseController {
    @Autowired
    private IBizClassService bizClassService;

    /**
     * 查询班组管理列表
     */
//    //@PreAuthorize("@ss.hasPermi('manager:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizClass bizClass) {
        startPage();
        List<BizClass> list = bizClassService.selectBizClassList(bizClass);
        return getDataTable(list);
    }

    /**
     * 导出班组管理列表
     */
    //@PreAuthorize("@ss.hasPermi('manager:class:export')")
    @Log(title = "班组管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizClass bizClass) {
        List<BizClass> list = bizClassService.selectBizClassList(bizClass);
        ExcelUtil<BizClass> util = new ExcelUtil<BizClass>(BizClass.class);
        return util.exportExcel(list, "class");
    }

    /**
     * 获取班组管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manager:class:query')")
    @GetMapping(value = "/{classID}")
    public AjaxResult getInfo(@PathVariable("classID") Long classID) {
        return AjaxResult.success(bizClassService.selectBizClassById(classID));
    }

    /**
     * 新增班组管理
     */
    //@PreAuthorize("@ss.hasPermi('manager:class:add')")
    @Log(title = "班组管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizClass bizClass) {
        return toAjax(bizClassService.insertBizClass(bizClass));
    }

    /**
     * 修改班组管理
     */
    //@PreAuthorize("@ss.hasPermi('manager:class:edit')")
    @Log(title = "班组管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizClass bizClass) {
        return toAjax(bizClassService.updateBizClass(bizClass));
    }

    /**
     * 删除班组管理
     */
    //@PreAuthorize("@ss.hasPermi('manager:class:remove')")
    @Log(title = "班组管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{classIDs}")
    public AjaxResult remove(@PathVariable Long[] classIDs) {
        return toAjax(bizClassService.deleteBizClassByIds(classIDs));
    }
}
